package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.fellingtrees.config.FellingTreesConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.fellingtrees.FellingTreesMgr;

import java.util.ArrayList;
import java.util.List;

public class FellingTreesRecycleStrategy extends AbstractItemRecycleStrategy {

    @Override
    public void markNeedRecycleItem() {
        FellingTreesConfig config = FellingTreesMgr.getFellingTreesConfig();
        if (config != null) {
            ActivityInfo activityInfo = config.getActivityInfo();
            long recycleTime = activityInfo.getEndTime() * 1000L + 600 * 1000;
            // 回收体力药
            List<String> energyList = new ArrayList<>();
            energyList.add(String.valueOf(config.getEnergyItemId()));
            energyList.add(String.valueOf(config.getScoreItemId()));
            energyList.add("1");
            energyList.add(activityInfo.getActivityName());
            ActivityItemRecycleMgr.addRecycleItemData(config.getEnergyItemId(), activityType, 1, recycleTime, energyList);
        }
    }

    @Override
    public boolean isActivityRunning() {
        ActivityInfo activityInfo = FellingTreesMgr.getActivityInfo();
        return ActivityMgr.activityInTime(activityInfo);
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.FellingTrees.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        item2Score(userId, data);
    }
}
